
var server_name = '/hidetail';

var access_url = basePath()+server_name;

//获取协议+ip+端口(结尾不带斜杠)
function basePath() {
    //获取当前网址，如： http://localhost:8080/ems/Pages/Basic/Person.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： /ems/Pages/Basic/Person.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8080
    var localhostPath = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/ems
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    //获取项目的basePath   http://localhost:8080/ems/
    var basePath = localhostPath + projectName + "/";
    return localhostPath;
}

$.ajaxSetup({
	headers : {
		"token" : sessionStorage.getItem("token")
	}
	/*,compelet:function(XMLHttpRequest,textStatus){
			alert('监听')
			if(XMLHttpRequest.status==800){
				alert("登陆已过期，请重新登陆");
				window.parent.location.href = "/login.html";
				return;
			}
		}*/
	,statusCode : {
		800 : function(data){
			console.log('进入800返回状态监听');
			
			/*alert('未通过验证，不允许登陆');
				window.parent.location.href = "/login.html";*/
			layui.use('layer', function(){
				layer.msg('未通过登陆验证，不允许访问  ',{
					time : 0
					,area : ['250px','100px']
					,shade : [0.3]
					,btn : ['确定']
					,btnAlign : 'c'
					,yes : function(index){
						window.parent.location.href = server_name+"/login.html";
					}
				})
			});  
		}
	}
})

/**
 * 获取读取图片的url路径
 */
function getReadFileUrl(fileUrl,saveType){
	if(!fileUrl){
		console.log('没有传入fileUrl')
		return 'miss fileUrl';
	}
	if(!saveType){
		console.log('没有传入saveType')
		return 'miss saveType';
	}
	let readFileUrl = `${access_url}/file/readfile?saveType=${saveType}&fileUrl=${fileUrl}`;
	return readFileUrl;
}